Skip to content

Conversation

@pytorchbot
Copy link
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #13156 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/267/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/267/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/267/orig
@diff-train-skip-merge

Note that although the volume of changes in this diff are very high, the changes themselves are extremely mechanical. This diff was written almost entirely with a LLM, but I have looked through each file and validated the changes.

## Changes


This diff updates callsites using `graph->get_tensor(value_ref)` in favor of just using the `ValueRef` directly.

A simple example (and the vast majority of changes in this diff) is a change such as:

```
vTensorPtr tensor = graph->get_tensor(tensor_ref);

some_fn(tensor->sizes());
```

To instead be

```
std::vector<int64_t> tensor_sizes = graph->sizes_of(tensor_ref);
some_fn(tensor_sizes);
```

or

```
some_fn(graph->sizes_of(tensor_ref));
```

## Motivation

Overall, the goal is to make the `get_tensor()` API protected so that it can only be used in specific situations.

In addition to the primary motivation of improving the consistency of API usage throughout the codebase, there is a practical benefit as well. `get_tensor` has a limitation that no values can be added to the graph while the `vTensorPtr` is in scope. Also, forcing tensor modifications via functions like `virtual_resize()` to go through the `ComputeGraph` will allow the graph to track changes for the purposes of determining when a command buffer re-encode or resize propagation is necessary, which will result in performance benefits.

Differential Revision: [D79564594](https://our.internmc.facebook.com/intern/diff/D79564594/)

ghstack-source-id: 301111044
Pull Request resolved: #13156
@pytorchbot pytorchbot requested a review from SS-JIA as a code owner August 6, 2025 19:54
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 6, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13167

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

⏳ No Failures, 92 Pending

As of commit faf19b9 with merge base 6bc312a (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 6, 2025
@github-actions
Copy link

github-actions bot commented Aug 6, 2025

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@SS-JIA SS-JIA merged commit 5488056 into main Aug 6, 2025
99 of 102 checks passed
@SS-JIA SS-JIA deleted the gh/SS-JIA/267/orig branch August 6, 2025 20:09
agrima1304 pushed a commit to agrima1304/executorch that referenced this pull request Aug 26, 2025
)

Note that although the volume of changes in this diff are very high, the changes themselves are extremely mechanical. This diff was written almost entirely with a LLM, but I have looked through each file and validated the changes.

## Changes


This diff updates callsites using `graph->get_tensor(value_ref)` in favor of just using the `ValueRef` directly.

A simple example (and the vast majority of changes in this diff) is a change such as:

```
vTensorPtr tensor = graph->get_tensor(tensor_ref);

some_fn(tensor->sizes());
```

To instead be

```
std::vector<int64_t> tensor_sizes = graph->sizes_of(tensor_ref);
some_fn(tensor_sizes);
```

or

```
some_fn(graph->sizes_of(tensor_ref));
```

## Motivation

Overall, the goal is to make the `get_tensor()` API protected so that it can only be used in specific situations.

In addition to the primary motivation of improving the consistency of API usage throughout the codebase, there is a practical benefit as well. `get_tensor` has a limitation that no values can be added to the graph while the `vTensorPtr` is in scope. Also, forcing tensor modifications via functions like `virtual_resize()` to go through the `ComputeGraph` will allow the graph to track changes for the purposes of determining when a command buffer re-encode or resize propagation is necessary, which will result in performance benefits.

Differential Revision: [D79564594](https://our.internmc.facebook.com/intern/diff/D79564594/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants